package com.smart.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.smart.common.annotation.Log;
import com.smart.common.core.controller.BaseController;
import com.smart.common.core.domain.AjaxResult;
import com.smart.common.enums.BusinessType;
import com.smart.manage.domain.DoctorAppointment;
import com.smart.manage.service.IDoctorAppointmentService;
import com.smart.common.utils.poi.ExcelUtil;
import com.smart.common.core.page.TableDataInfo;

/**
 * 医生预约管理Controller
 * 
 * @author lingyao
 * @date 2025-03-03
 */
@RestController
@RequestMapping("/manage/doctorAppointment")
public class DoctorAppointmentController extends BaseController
{
    @Autowired
    private IDoctorAppointmentService doctorAppointmentService;

    /**
     * 查询医生预约管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:doctorAppointment:list')")
    @GetMapping("/list")
    public TableDataInfo list(DoctorAppointment doctorAppointment)
    {
        startPage();
        List<DoctorAppointment> list = doctorAppointmentService.selectDoctorAppointmentList(doctorAppointment);
        return getDataTable(list);
    }

    /**
     * 导出医生预约管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:doctorAppointment:export')")
    @Log(title = "医生预约管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DoctorAppointment doctorAppointment)
    {
        List<DoctorAppointment> list = doctorAppointmentService.selectDoctorAppointmentList(doctorAppointment);
        ExcelUtil<DoctorAppointment> util = new ExcelUtil<DoctorAppointment>(DoctorAppointment.class);
        util.exportExcel(response, list, "医生预约管理数据");
    }

    /**
     * 获取医生预约管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:doctorAppointment:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(doctorAppointmentService.selectDoctorAppointmentById(id));
    }

    /**
     * 新增医生预约管理
     */
    @PreAuthorize("@ss.hasPermi('manage:doctorAppointment:add')")
    @Log(title = "医生预约管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DoctorAppointment doctorAppointment)
    {
        return toAjax(doctorAppointmentService.insertDoctorAppointment(doctorAppointment));
    }

    /**
     * 修改医生预约管理
     */
    @PreAuthorize("@ss.hasPermi('manage:doctorAppointment:edit')")
    @Log(title = "医生预约管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DoctorAppointment doctorAppointment)
    {
        return toAjax(doctorAppointmentService.updateDoctorAppointment(doctorAppointment));
    }

    /**
     * 删除医生预约管理
     */
    @PreAuthorize("@ss.hasPermi('manage:doctorAppointment:remove')")
    @Log(title = "医生预约管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(doctorAppointmentService.deleteDoctorAppointmentByIds(ids));
    }
}
